package grailsworkshop2012_1_f

class CurrentController {

    def index = {
        redirect(action:"current")
    }
    
    def current = {
        def trips = Trip.executeQuery("select distinct trip.purpose from Trip trip", [])
        [trips: trips]
    }
    
    def tripByPurpose() {
        def budgets = Budget.withCriteria {
            trip {
                eq("purpose", params.trips)
            }
        }
        [budgets: budgets]
    }
    
    def allTrips() { 
        def allTrips = Budget.list()
        [allTrips:allTrips]
    }
}

